package com.umerclass.ui.home.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.RequestManager;
import com.umerclass.R;
import com.umerclass.bean.home.ItemOneBean;
import com.umerclass.frame.ui.recycleview.adapter.RecyclerviewBasicAdapter;
import com.umerclass.frame.ui.recycleview.base.ViewHolder;
import com.umerclass.frame.ui.recycleview.listener.OptListener;
import java.util.List;

/**
 * Created by jack
 */

public class ItemAdapterOne extends RecyclerviewBasicAdapter<ItemOneBean> {

    private OptListener optListener;
    private RequestManager glideRequestManager;

    public ItemAdapterOne(Context context, List datas, int layoutId, RequestManager glideRequestManager,
                          OptListener optListener) {
        super(context, datas, layoutId);
        this.optListener = optListener;
        this.glideRequestManager = glideRequestManager;
    }

    public ItemAdapterOne(Context context, List datas, int layoutId, OptListener optListener) {
        super(context, datas, layoutId);
        this.optListener = optListener;
    }

    @Override
    public void convert(ViewHolder holder, final ItemOneBean bean, final int position) {

        LinearLayout linear = holder.getView(R.id.linear);
        ImageView iv = holder.getView(R.id.iv);
        TextView tv = holder.getView(R.id.tv);
        /*glideRequestManager
                .load(Constants.IP_PORT_DEFAULT_PICTURE + bean.getPath())
                .centerCrop()
                .dontAnimate()
                .thumbnail(0.5f)
                .placeholder(R.drawable.default_pic)
                .error(R.drawable.default_pic)
                .into(iv);*/
        if(position == 0){
            glideRequestManager.load(R.drawable.one_icon).into(iv);
        }else if(position == 1){
            glideRequestManager.load(R.drawable.two_icon).into(iv);
        }else if(position == 2){
            glideRequestManager.load(R.drawable.three_icon).into(iv);
        }else if(position == 3){
            glideRequestManager.load(R.drawable.four_icon).into(iv);
        }else if(position == 4){
            glideRequestManager.load(R.drawable.four_icon).into(iv);
        }
        /*glideRequestManager
                .load(bean.getPath())
                .centerCrop()
                .dontAnimate()
                .thumbnail(0.5f)
                .placeholder(R.drawable.default_pic)
                .error(R.drawable.default_pic)
                .into(iv);*/
        tv.setText(bean.getName());
        linear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });
    }

}
